 
 
 //轮播图的style改成数组
 var arr=[
     {x:-64,s:0.83,z:1},
     {x:140,s:1,z:2},
     {x:338,s:0.83,z:1},
     {x:960,s:0.83,z:1},
     {x:960,s:0.83,z:1},
     {x:960,s:0.83,z:1},
 ]
//获取全部轮播图，遍历
function swiper(){
var imgObj = document.querySelectorAll(".swiper .swiper-wrapper .swiper-slide")
 imgObj.forEach(function(item,i){
    item.style.transform ="translateX("+arr[i].x+"px) scale("+arr[i].s+")"
    item.style.zIndex = arr[i].z
 })
}
swiper()


function prev(){
  // 数组中第一个弹出
  var temp = arr.shift()
  //后压给数组
  arr.push(temp)
   swiper()
}

var prevObj = document.querySelector(".swiper-prev")
prevObj.onclick= function(){
    prev()
}

function next(){
    //数组中最后一个弹出
    var temp = arr.pop()
    //前压给数组
    arr.unshift(temp)
    swiper()
}
var nextObj = document.querySelector(".swiper-next")
nextObj.onclick = function(){
    next()
}

//点图切换图片
var imgObj = document.querySelectorAll(".swiper .swiper-wrapper .swiper-slide")
imgObj.forEach(function(item,i){
    item.onclick = function (){
        var style = item.style.transform
        if (style.includes('-64px')) {   
            //includes 返回true表示找到了，flase表示未找到
            // 也可以：style.includes('-64px')==true
            prev()
        }
        if (style.includes('338px')) {
            next()
        }
    }
})

